package web.manager;

import bean.Manager;
import bean.Staff;
import bean.Video;
import com.alibaba.fastjson.JSON;
import entity.ManagerEntity;
import entity.StaffEntity;
import entity.VideoEntity;
import util.FANREN;

import javax.persistence.EntityManager;
import javax.persistence.Query;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "PwdEdit", urlPatterns = "/dao/update/pwdEdit")
public class PwdEdit extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String pwd = FANREN.getJson(request);
        EntityManager em = (EntityManager) request.getAttribute("_entity.Manager");
        Manager manager = (Manager) request.getSession().getAttribute("manager");
        ManagerEntity managerEntity = em.find(ManagerEntity.class,manager.getMid());
        managerEntity.setPwd(pwd);
        em.persist(managerEntity);
        manager.setPwd(pwd);
    }

}

